Conway’s Game of Life – Cellular Automaton is a Unity-based interactive simulation that visualizes the emergent behavior of cellular automata as defined by mathematician John Conway.
This project was developed to explore simulation design, optimization techniques, and procedural content generation in Unity. By implementing the Game of Life ruleset using object pooling, dynamic grid generation, and real-time UI feedback, the project demonstrates proficiency in system architecture, performance management, and visual data representation.
The Game of Life is a zero-player game that evolves based on an initial state and a set of deterministic rules. Each cell in a grid can be alive or dead, and its fate in the next generation depends on the number of living neighbors it has.
The objective of this Unity project was to create a scalable, efficient, and visually intuitive version of this simulation that runs smoothly at high resolutions while remaining interactive and informative.
The emphasis was on clarity and scalability — creating a foundation for future extensions like alternate automaton rules, color-coding systems, or user-drawn initial states.
The simulation is composed of three primary components:
This modular design ensures a clear separation between visualization, simulation logic, and user interface.
At startup, the program initializes a two-dimensional array of cells (Cell[,] grid) with configurable width and height.
Each grid position has a random 30% chance of starting as alive. Live cells are obtained from a pre-allocated pool rather than dynamically instantiated — a key optimization decision for performance.
The camera is automatically positioned and scaled to ensure the entire grid remains visible regardless of dimensions:
Camera.main.transform.position = new Vector3(0, 0, -10);
Camera.main.orthographicSize = (height * cellSize) / 2f;
This ensures visual consistency even when the grid resolution is changed.
The core algorithm runs at a fixed time interval (0.1 seconds) via InvokeRepeating.
Each update performs the following sequence:
For each cell, the program counts its eight surrounding neighbors using a doubleloop over the offset range (-1, 1).
The simulation applies Conway’s rules:
The new generation is stored in a secondary 2D array (nextGen) beforeapplying the updates to the grid.
This approach ensures synchronous updates, maintaining correct simulation behavior.
With potentially over 20,000 cells on screen, naïve object creation and destruction each frame would quickly degrade performance.
To solve this, the project uses a custom object pooling system implemented via a Queue
Cell GetCellFromPool(int x, int y) {
Cell cell = cellPool.Dequeue();
cell.transform.position = position;
cell.gameObject.SetActive(true);
return cell;
}
This drastically reduces garbage collection spikes and ensures smooth frame rates — a key factor when rendering large-scale automata.
The Cell class handles only visual state:
public void SetState(bool state) {
spriteRenderer.color = state ? Color.white : Color.black;
}
This clean separation allows for easy stylistic updates (e.g., color gradients for aging cells).
Additionally, the GameOfLife script updates a UI text element in real time:
Generation:
Population:
This turns the simulation into an educational tool by displaying meaningful metrics about system evolution and entropy over time.
Although primarily automatic, the simulation allows limited input for control:
This minimal interactivity supports experimentation while preserving the integrity of the automated evolution process.
| Component | Role | Key Features |
|---|---|---|
| Cell.cs | Visual unit class | Sprite-based rendering, binary alive/dead state |
| GameOfLife.cs | Simulation core | Grid management, rule computation, pooling, statistics |
| GameUI.cs | User interface prototype | Start/pause toggle (future feature), info display |
| UnityEngine & UI | Framework | Physics-less rendering, performance control, camera scaling |
The architecture is designed to be data-driven — simulation logic depends only on grid data, not object hierarchy, ensuring scalability and maintainability.
Early versions instantiated thousands of cells directly in the scene, resulting in stutter and frame drops.
Solution: Introduced an object pooling system that recycles cells efficiently.
Out-of-bounds array access occurred during neighbor checking near grid edges.
Solution: Implemented boundary checks before counting neighbors:
if (nx >= 0 && ny >= 0 && nx < width && ny < height)
Updating the grid in place led to “ripple errors” where changes propagated incorrectly within the same frame.
Solution: Used a double-buffer system (grid and nextGen) to separate current and next states before applying updates.
Restarting the simulation left old cells active on screen.
Solution: Added a RestartGame() method that cleanly resets the grid, pool, and counters before reinitializing.
Testing involved adjusting:
Each test iteration measured frame rate consistency and verified correct application of Conway’s rules (e.g., still lifes, oscillators, gliders).
Iterations also validated the population counter, confirming accurate tracking of live cell counts across generations.
The finished simulation successfully:
The final product effectively bridges mathematical logic and visual interaction, highlighting the elegance of emergent complexity from simple rules.
Key takeaways from the development process include:
Planned or potential enhancements include:
These extensions would transform the project into a fully interactive laboratory for procedural simulation and emergent behavior study.
Conway’s Game of Life – Cellular Automaton serves as both a technical showcase and a conceptual exploration.
It demonstrates how a timeless algorithm can be translated into a modern, optimized, and interactive experience through Unity.
Through the development of this project, I strengthened my understanding of:
This project stands as a compelling example of my ability to design, optimize, and communicate complex systems with clarity and precision — an essential skillset in both game development and interactive simulation design.